package com.librelato.negocio;

import java.sql.Date;
import java.util.List;
import java.util.Map;

import com.librelato.bean.ChamadoBean;
import com.librelato.bean.UsuarioBean;
import com.librelato.negocio.interfaces.IChamadoServico;
import com.librelato.persistencia.ChamadoDao;
import com.librelato.persistencia.interfaces.IChamadoDao;
import com.librelato.persistencia.interfaces.IDaoGenerico;

public class ChamadoServico<P extends ChamadoBean> extends ServicoGenerico<P>
		implements IChamadoServico<P> {

	private IChamadoDao<ChamadoBean> dao;

	public ChamadoServico() {
		this.dao = new ChamadoDao<ChamadoBean>();
	}

	public void excluir(final P p) throws Exception {
		this.dao.excluir(p);
	};
	
	public void editar(final P p) throws Exception {
		this.dao.editar(p);
	};

	@SuppressWarnings("unchecked")
	@Override
	public P salvar(final P p) throws Exception {
		return (P) this.dao.salvar(p);
	}
	
	public void aprovaChamado(P p) throws Exception {
		this.dao.aprovaChamado(p);		
	};
	
	public void trocaDestinoChamado(P p) throws Exception {
		this.dao.trocaDestinoChamado(p);		
	};
	
	public void negaChamado(P p) throws Exception {
		this.dao.negaChamado(p);
	};

	@SuppressWarnings("unchecked")
	@Override
	public List<P> buscaChamadosAberto(Map<String, String> param,UsuarioBean p) throws Exception {

		return (List<P>) this.dao.buscaChamadosAberto(param,p);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<P> buscaChamadosNaoAprovados(Map<String, Object> param,UsuarioBean p) throws Exception {
		return (List<P>) this.dao.buscaChamadosNaoAprovados(param,p);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<P> buscaChamadosAtendidos(Map<String, Object> param,
			UsuarioBean p) throws Exception {
		return (List<P>) this.dao.buscaChamadosAtendidos(param, p);
	}

	public void insereQualificacao(P p) throws Exception {
		this.dao.insereQualificacao(p);
	}

	public void insereQualificacaoInsatisfeito(P p) throws Exception {
		this.dao.insereQualificacaoInsatisfeito(p);
	};

	@SuppressWarnings("unchecked")
	@Override
	public List<P> buscaChamadosFinalizado(Map<String, String> param,
			UsuarioBean p) throws Exception {

		return (List<P>) this.dao.buscaChamadosFinalizado(param, p);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<P> buscaChamadosIniciar(Map<String, Object> param,UsuarioBean p) throws Exception {
		return (List<P>) this.dao.buscaChamadosIniciar(param,p);
	}
	
	@Override
	public List<Long> estatisticaChamadoUsuario(UsuarioBean p) throws Exception {
		return this.dao.estatisticaChamadoUsuario(p);
	}
	
	@Override
	public List<List<String>> estatisticaTI(UsuarioBean p) throws Exception {
		return this.dao.estatisticaTI(p);
	}
	
	@Override
	public List<List<String>> estatisticaAssunto(UsuarioBean p)
			throws Exception {
		return this.dao.estatisticaAssunto(p);
	}
	
	public void iniciaChamado(P p) throws Exception {
		this.dao.iniciaChamado(p);
	};
	
	public void informaAndamento(P p) throws Exception {
		this.dao.informaAndamento(p);
	};

	@Override
	public IDaoGenerico<P> getDao() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void preSalvar(P p) {
		// TODO Auto-generated method stub

	}

	@Override
	public void posSalvar(P p) {
		// TODO Auto-generated method stub

	}

	@Override
	public Map<String, Map<String, Long>> buscaTotalPorStatus(
			Date dataDe, Date dataAte,String queryParam) throws Exception {
		return this.dao.buscaTotalPorStatus(dataDe, dataAte, queryParam);
	}

	@Override
	public Map<String, Map<String, Long>> buscaTotalNotaMes(Date dataDe,
			Date dataAte) throws Exception {
			return this.dao.buscaTotalNotaMes(dataDe, dataAte);
	}

	@Override
	public List<ChamadoBean> buscaChamadosNaoQualificados(
			Map<String, String> param) throws Exception {
		// TODO Auto-generated method stub
		return this.dao.buscaChamadosNaoQualificados(param);
	}
}
